// ValidationAspects
// Written by Mike Saunders
// Released under Microsoft Public License (Ms-PL)
using System;
using ValidationAspects.Exceptions;

namespace ValidationAspects.Core
{
	internal static class Cast<T>
	{
		public static T From(object value)
		{
			try
			{
				return (T)value;
			}
			catch (InvalidCastException e)
			{
				throw new UnsupportedValidationException(string.Format("Failed to cast [type:{0}] to [type:{1}] for validation.", value.GetType(), typeof(T)), e);
			}
		}
	}
}